Support RBS signatures in check-shims command #2482
+94
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The
check-shimscommand detects duplicate definitions between shim files and generated RBIs. It correctly ignores duplicates when the shim adds asigblock (since the shim is adding type information, not just duplicating). However, it doesn't recognize RBS comment syntax (#:) as a signature, so shims using RBS syntax are incorrectly flagged as duplicates.With Sorbet's RBS support, users can now write type signatures using RBS comments instead of
sigblocks. Thecheck-shimscommand should treat these equivalently.Implementation
Modified
has_duplicated_methods_and_attrs?inRBIFilesHelperto check forRBI::RBSCommentinstances in a node'scommentsarray, in addition to checking thesigsarray. The logic mirrors the existing signature handling:Added a small helper method
extract_rbs_commentsto extract RBS comments from a node.Tests
Added 3 new tests mirroring the existing
sigblock tests:ignores duplicates that have an RBS signatureignores duplicates that have a different RBS signaturedetects duplicates that have the same RBS signature